<template>
	<view class="content">
		<view class="header">
			<view class="ipt-box">
				<input v-model="number" type="text" value="" placeholder="请输入搜索内容" placeholder-class="plac-class" />
				<image src="../../static/search1.png" mode="" @click="searchList"></image>
			</view>
			<view class="header-right">
				<easy-select class="easySelect" style="width:400upx;height:100%;font-size: 24upx;color: #fff;"
					:options="options" ref="easySelect" size="medium" :value="selecValue" @selectOne="selectOne">
				</easy-select>
			</view>
		</view>
		<view class="">

		</view>
		<view class="danger-box">
			<view class="danger-item" v-for="(item,index) in dangerList" :key="index">
				<view class="safe">
					<image src="../../static/aqy.png" mode=""></image>{{item.role_name}}
				</view>
				<view>标题：{{item.title}}</view>
				<view class="miaosu">地址：<a _blank :href="item.upload_file">{{item.upload_file}}</a></view>
				<view class="miaosu">描述：{{item.desc}}</view>
				<view>上传日期：{{item.cteate_time}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../common/request.js'
	export default {
		data() {
			return {
				username: '',
				password: '',
				// array: ['安装工','检测工','维修工'],
				index: 0,
				userinfo: {},
				value: '', //搜索关键词
				installList: [], //安装列表
				dosearch: false,
				showAcount: false,
				page: 1,
				dangerList: [],
				active: 1,
				trackName: 1,
				selecValue: '类型1',
				options: [],
				number: '',
				totwn: ''
			};
		},
		onLoad() {
			this.userinfo = this.user
			// this.getInstallDetail()
		},
		onShow() {
			uni.getStorage({
				key: 'token'
			}).then(da => {
				this.token = da[1].data
				this.getInstallDetail()
				this.getList()
			})

		},
		//下拉刷新
		onPullDownRefresh() {
			this.page = 1
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 500);
			this.getInstallDetail()
		},
		onReachBottom() {
			if (this.page >= this.totwn) {
				uni.showToast({
					title: '没有更多数据',
					icon: 'none'
				})
				return
			} else {
				this.page++
				this.getInstallDetail()
			}

		},
		methods: {
			selectOne(option) {
				this.dangerList = []
				this.selecValue = option.label
				this.trackName = option.id
				this.getInstallDetail()
			},
			getList() {
				let that = this
				request.request({
					url: 'common/material_type',
					method: 'POST',
					data: {
						token: that.token
					}
				}).then((res)=>{
					that.options = res.data.data
					console.log(that.options);
				})
			},
			navClick(i) {
				this.dangerList = []
				this.active = i + 1
				this.getInstallDetail()
				console.log(this.active)
			},
			searchList() {
				if (this.number == '') {
					uni.showToast({
						title: '请输入编号查找',
						icon: 'none'
					})
					this.getInstallDetail()
					return
				} else {
					this.getInstallDetail()
				}
			},
			searchFocus() {
				this.showAcount = false
			},
			infoClick() {
				this.showAcount = !this.showAcount
			},
			// 跳转至记录页面
			toJiLu() {
				uni.navigateTo({
					url: './jilu'
				})
			},
			// 跳转用户信息页面
			toCaiLiao(id) {
				uni.navigateTo({
					url: '../userinfo/uninstall?id=' + id
				})
			},
			// 点击获取安装数据
			searchUser(val) {
				// this.getInstallDetail ()
				this.dosearch = true
				uni.navigateTo({
					url: '../query/query?key=' + val
				})
			},
			// 获取安装数据
			getInstallDetail() {
				let that = this

				request.request({
					url: 'common/material_list',
					method: 'POST',
					data: {
						token: that.token,
						keyword: that.number,
						type: this.trackName, //检索的类型  就是id
						// page: that.page,
						// status: that.trackName,
						// type: that.active,
						// token: that.token,
						// no: that.number
					}
				}).then(res => {
					if (res.data.code == 1) {
						that.totwn = res.data.data.page_count
						that.dangerList = res.data.data.data
						console.log(that.dangerList)
					} else {
						uni.showToast({
							title: '没有更多数据',
							icon: 'none'
						})
						that.number = ''
						return
					}
				})
			},
		},

	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #F5F5F5;
		// padding-bottom: 200upx;
		// margin-bottom: 150upx;
	}

	.content {
		padding-bottom: 140upx;
	}

	.header1 {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30upx 30upx;
		background-color: #fff;

		.header-left {
			display: flex;
			align-items: center;
			font-size: 32upx;
			font-weight: 500;
			color: #333;

			image {
				width: 24upx;
				height: 24upx;
				margin-right: 20upx;
			}
		}

		.header-right {
			display: flex;
			align-items: center;
			font-size: 24upx;
			color: #333;

			image {
				width: 52upx;
				height: 52upx;
				margin-right: 10upx;
			}
		}
	}

	.header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
		height: 80upx;
		width: 100%;
		background-color: #003690;
		padding: 0 40upx;

		.ipt-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 0 20upx;
			width: 514upx;
			height: 52upx;
			background-color: #fff;
			border-radius: 24upx;

			image {
				width: 32upx;
				height: 32upx;
			}
		}

		.header-right {
			display: flex;
			align-items: center;
			font-size: 32upx;
			color: #E2ECFB;
			position: relative;

			image {
				width: 36upx;
				height: 36upx;
			}

			.genFle {
				position: absolute;
				top: 64upx;
				left: 0;
				width: 100%;
				background-color: #fff;
				border: 2upx solid #ccc;
				color: #003690;
				text-align: center;
				z-index: 999;

				view {
					border-bottom: 2upx solid #ccc;
					line-height: 60upx;
				}
			}
		}
	}

	.test-code:active {
		background: rgba(69, 82, 202, 0.4);
		color: #fff;
	}

	.plac-class {
		font-size: 32upx;
		color: #999;
	}

	// nav
	.nav {
		width: 100%;
		height: 80upx;
		background-color: #fff;

		.nav-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 50%;
			margin: 0 auto;
			line-height: 76upx;

			span {
				padding: 0 10upx;
				font-size: 32upx;
				color: #333;
				border-bottom: 4upx solid transparent;
			}

			.current {
				color: #003690;
				border-bottom: 4upx solid #003690;
			}
		}
	}

	// danger
	.danger-item {
		position: relative;
		box-sizing: border-box;
		width: 690upx;
		padding: 30upx;
		background-color: #fff;
		border-radius: 10upx;
		margin: 30upx auto 0;
		box-shadow: 0px 3px 4px rgba(0, 30, 57, 0.15);

		.safe {
			color: #003690;
			font-size: 24upx;
			line-height: 38upx;

			image {
				width: 36upx;
				height: 36upx;
				margin-right: 6upx;
				vertical-align: bottom;
			}
		}

		.miaosu {
			width: 60%;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}

		.kong {
			display: inline-block;
			width: 56upx;
		}

		.kong1 {
			display: inline-block;
			width: 14upx;
		}

		.shenhe {
			position: absolute;
			top: 20upx;
			right: 20upx;
			width: 170upx;
			height: 170upx;
		}
	}
</style>
